import { repairStatus } from '../../../constants/status'

Page({
  data: {
    list: [],
    isFirst: true,
    repairStatus,
  },
  goDetail(e) {
    // 跳转到详情页并传递维修单id
    wx.navigateTo({
      url: `/repair_pkg/pages/detail/index?id=${e.mark.id}`,
    })
  },
  addRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index',
    })
  },
  // 页面显示时触发
  onShow() {
    // 获取报修列表数据
    this.getRepairList()
  },
  // 报修列表接口
  async getRepairList() {
    // 调用接口
    const res = await wx.http.get('/repair', { current: 1, pageSize: 10 })
    // 渲染数据
    this.setData({
      list: res.data.rows,
      isFirst: false,
    })
  },
})
